from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from items.cellphone import Cellphone
from items.coffin import Coffin
from items.propeller import Propeller
from items.floss import Floss
from rooms.victory_room import VictoryRoom
from core.support import get_game
#Dont need this room
class BeachRoom(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        self.add_item(Cellphone())
        self.add_item(Coffin())
        self.add_item(Propeller())
        self.add_item(Floss())
       
        # build list of actions
        self.add_action(Exit)
        self.add_action(MakeEpicGetaway)
    
    # return description of room.
    def get_description(self):
        return "MacGyver finds himself standing on the shoreline of a vast ocean"
    
    # return image of room
    def get_image(self):
        return 'scene5_beach_debris.jpg'

class BeachRoomHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return BeachRoom

# define actions for this room

class Exit(Action):
    def __init__(self):
        Action.__init__(self, "Exit")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Return to Prison Yard"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'prisonyard'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        return get_game().get_player().has_item('rope')

class MakeEpicGetaway(Action):
    def __init__(self):
        Action.__init__(self, "MakeEpicGetaway")
    
    def do_action(self,game,room,request):
        game.get_room('victory_room',VictoryRoom).set_image('jetski.gif')
        game.get_room('victory_room',VictoryRoom).set_description('You assembled a getaway coffin-jetski.  You have won the game!  Congratulations!')
        game.get_room('victory_room',VictoryRoom).set_audio('MacGyver.mp3')
        return
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Make Epic Getaway"
    
    def get_destination(self):
        return "victory_room"
    
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        game = get_game()
        player = game.get_player()
        return (player.has_item('propeller') and player.has_item('coffin') and player.has_item('floss'))